<style>

    .cardU {
        background-image: url(../../../assets/images/card_u.png);
        background-repeat: no-repeat;
        background-position: center;
        width:calc(100% - 120px);
        height: 150px;
        padding: 0;
    }

    .cardU img {
        width: 100%;
        height: 100%;
    }
</style>
<div id="formDiv"></div>
<script type="text/html" id="shipmentOrderSignForm">
    <form lay-filter="SignFormContent" id="SignFormContent" class="layui-form open-form">
        <div class="open-model">
            <div class="open-auto">
                <div>
                    <table class="layui-table">
                        <thead>
                        <tr>
                            {{# if(d.eventName !== 'detail'){ }}
                            <th lay-data="{field:'shipmentOrderCode', width:150, sort: true, fixed: 'left'}">
                                发货运单号
                            </th>
                            {{# } }}
                            <th lay-data="{field:'materialName', width:150, sort: true, fixed: 'left'}">数据来源
                            </th>
                            <th lay-data="{field:'materialSpec', width:150, sort: true, fixed: 'left'}">所属合同编号</th>
                            <th lay-data="{field:'materialUnit', width:150, sort: true, fixed: 'left'}">客户代码</th>
                            <th lay-data="{field:'materialSpec', width:150, sort: true, fixed: 'left'}">
                                物料重量
                            </th>
                            <th lay-data="{field:'materialSpec', width:150, sort: true, fixed: 'left'}">发货记录编号</th>
                            <th lay-data="{field:'materialUnit', width:150, sort: true, fixed: 'left'}">车牌号</th>
                            <th lay-data="{field:'materialUnit', width:150, sort: true, fixed: 'left'}">司机</th>
                            <th lay-data="{field:'materialUnit', width:150, sort: true, fixed: 'left'}">司机电话</th>
                            <th lay-data="{field:'materialUnit', width:150, sort: true, fixed: 'left'}">状态
                            </th>
                            <th lay-data="{field:'materialUnit', width:150, sort: true, fixed: 'left'}">入库仓库
                            </th>
<!--                            <th lay-data="{field:'materialUnit', width:150, sort: true, fixed: 'left'}">签收时间-->
<!--                            </th>-->
<!--                            <th lay-data="{field:'materialUnit', width:150, sort: true, fixed: 'left'}">签收人-->
<!--                            </th>-->
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            {{# if(d.eventName !== 'detail'){ }}
                            <td class="chooseCode">

<!--                                <select id="waybillI" name="waybillI"-->
<!--                                        lay-filter="waybillI" lay-search required></select>-->
                                <input class="layui-input adv-disable" id="waybillI"  lay-filter="waybillI" placeholder="请选择发货运单号" readonly name="waybillI" lay-search required />
                            </td>
                            {{# } }}

                            <td>
                                <input class="layui-input adv-disable" id="source" disabled
                                       name="source"/>
                            </td>
                            <td>
                                <input type="text" class="layui-input" disabled id="contractCode"
                                       name="contractCode"/>
                            </td>
                            <td>
                                <input type="text" class="layui-input" disabled id="warehouseCustomerId"
                                       name="warehouseCustomerId"/>
                            </td>
                            <td>
                                <input class="layui-input adv-disable" id="totalWeight" disabled
                                       name="totalWeight"/>
                            </td>
                            <td>
                                <input class="layui-input adv-disable" id="shipmentOrderCodeID" disabled
                                       name="shipmentOrderCode"/>
                            </td>
                            <td>
                                <input type="text" class="layui-input" disabled name="plateNo"/>
                            </td>

                            <td>
                                <input type="text" class="layui-input" disabled name="driverName"/>
                            </td>
                            <td>
                                <input type="text" class="layui-input" disabled name="driverPhone"/>
                            </td>
                            <td>
                                <input type="text" class="layui-input" disabled name="shipmentOrderStatusName"/>
                            </td>
                            {{# if(d.eventName !== 'detail'){ }}
                            <td class="chooseCode">

                                <select id="warehouseId" name="warehouseId"
                                        lay-filter="warehouseId" lay-search required></select>
                            </td>
                            {{# } }}
                            {{# if(d.eventName === 'detail'){ }}
                            <td class="chooseCode">
                                <input type="text" class="layui-input" disabled name="warehouseName"/>
                            </td>

                            {{# } }}
<!--                            <td>-->
<!--                                <input class="layui-input adv-disable" id="createTime" disabled name="createTime"/>-->
<!--                            </td>-->
<!--                            <td>-->
<!--                                <input class="layui-input adv-disable" id="creatorName" disabled-->
<!--                                       name="creatorName"/>-->
<!--                            </td>-->
                        </tr>
                        </tbody>
                    </table>
                </div>
                <!--      <div class="layui-form-item tableContent">-->
                <!--        <table class="layui-table" id="signFormtable" lay-filter="signFormtable"></table>-->
                <!--      </div>-->
                <div class="layui-form-item tableContent" id="signC">
                    <table class="layui-table" id="signCheckFormTable" lay-filter="signCheckFormTable"></table>
                </div>
            </div>
            <div class="layui-form-item text-right">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                {{# if(d.eventName !== 'detail'){ }}
                <button class="layui-btn" lay-filter="signcheckFormSubmit" type="button" lay-submit id="signcheckFormSubmit">批量签收</button>
                {{# } }}
            </div>
        </div>
    </form>
</script>
<!--签收操作-->
<script type="text/html" id="signcheckFormTableBar">
    {{# if(d.isSign !== '1'){ }}
    <button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="signClick" type="button">签收</button>
    {{# } }}
    {{# if(d.isSign === '1'){ }}
    <button class="layui-btn layui-btn-danger layui-btn-xs" disabled type="button">已签收</button>
    <button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="preview" type="button">预览</button>
    {{# } }}
    {{# if(d.isReview != '1'&&d.isSign === '1'){ }}
    <button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="review" type="button">复核</button>
    {{# } }}
</script>
<script type="text/html" id="unqualifiedForm">
    <form lay-filter="unqualifiedForm" class="layui-form model-form">
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>不合格原因</label>
            <div class="layui-input-block">
                <select name="unqualifiedId" id="unqualifiedId" lay-filter="unqualifiedId" lay-search lay-verify="required"></select>
            </div>
        </div>
        <div class="layui-form-item">
                <label class="layui-form-label">不合格图片</label>
                <div class="layui-upload-drag cardU" id="pictureDiv">
                    <!--<i class="layui-icon"></i>
                    <p>点击上传，或将文件拖拽到此处</p>-->
                    <input type="hidden" name="picture" lay-verify="" data-name="不合格图片">
            </div>
        </div>

        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" type="button" id="saveMaterialInfo" lay-filter="saveMaterialInfo" lay-submit>保存</button>
        </div>
    </form>
</script>
<script>
    layui.use(["layer", "form", "table", "admin", "laydate", "upload", "laytpl"], async function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        let laydate = layui.laydate;
        let laytpl = layui.laytpl;
        const nowData = { ...parentData };
        let data = nowData?.data;
        let skuList = [];
        var warehouseAreaList = [];
        var reasonShow=0;
        var formData={}
        const typeList=[
            {
                val:1,name:'普通物资'
            },{
                val:2,name:'加工预料'
            },{
                val:3,name:'加工原料'
            },{
                val:4,name:'加工成品'
            }
        ]
        const signQualifiedList=[
            {
                val:1,name:'合格'
            },{
                val:0,name:'不合格'
            }
        ]
        const statusList=[
            {val:1,name:'已受理'},
            {val:2,name:'发货中'},
            {val:3,name:'入库完成'},
            {val:0,name:'待受理'},
            {val:4,name:'已签收'},
        ]
        const statusListAdd=[
            {val:1,name:'待签收'},
            {val:2,name:'已签收'},
            {val:3,name:'已入库'},
            {val:0,name:'已撤销'},
        ]

        laytpl(shipmentOrderSignForm.innerHTML).render(nowData, function (html) {
            $("#formDiv").after(html);
        });
        if (nowData.eventName === "detail") {
            admin.setFormDisable("#SignFormContent", true);
            form.render();
            $("#shipmentOrderCode").html(nowData.data.shipmentOrderCode);
        }

        await admin.initDataSelectPro(
            "warehouse/warehouse/shipmentOrder/list",
            {limit: 99999},
            "waybillI",
            "发货运单号",
            async (d, obj) => {
                var item = {
                    shipmentOrderCode: "",
                    source: '',
                    contractCode: '',
                    warehouseCustomerId : '',
                    totalWeight : '',
                    plateNo: '',
                    waybill : '',
                    driverName  : '',
                    driverPhone: '',
                    shipmentOrderStatus: '',
                    createTime: '',
                    creatorName: ''
                }
                form.val("SignFormContent", item);
                // 清空排产信息列表
                table.reload("signCheckFormTable", {
                    data: []
                });
                if (obj) {

                }
                if (d.value) {
                    let kData = await admin.reqPro("warehouse/warehouse/signOrder/addInfo", {waybill: d.value});
                    let shipmentOrderCodeData=kData.data
                    if(shipmentOrderCodeData.source==2){
                        shipmentOrderCodeData.source='管理后台'
                    }
                    let info=statusListAdd.filter(item=>item.val==shipmentOrderCodeData.shipmentOrderStatus)
                    if(info.length){
                        shipmentOrderCodeData.shipmentOrderStatusName=info[0].name
                    }
                    let shipmentOrderDetailInfoList=shipmentOrderCodeData.orderInfoDetail
                    shipmentOrderDetailInfoList.map(item=>item.signQualified=1)
                    formData=shipmentOrderCodeData
                    table.reload("signCheckFormTable", {
                        data: shipmentOrderDetailInfoList
                    });
                    form.val("SignFormContent", shipmentOrderCodeData);
                } else {
                }

            },
            "waybill","waybill"
        );

        $("#waybillI").click(function () {
            if (nowData.eventName === "detail") {
                return;
            }
            admin.formOpen({
                area: "90%",
                offset: ['6%', '6%'],
                title: "选择签收选择运单号",
                path: "components/warehouse/product/signOrderSelect.html",
                success: function () {

                },
                end: async function () {
                    var item = {
                        shipmentOrderCode: "",
                        source: '',
                        contractCode: '',
                        warehouseCustomerId : '',
                        totalWeight : '',
                        plateNo: '',
                        waybill : '',
                        driverName  : '',
                        driverPhone: '',
                        shipmentOrderStatus: '',
                        createTime: '',
                        creatorName: ''
                    }
                    if(childData.SelectList && childData.SelectList.length){
                        let data=childData.SelectList[0]
                        let kData = await admin.reqPro("warehouse/warehouse/signOrder/addInfo", {waybill: data.waybill});
                        let shipmentOrderCodeData=kData.data
                        shipmentOrderCodeData.waybillI=data.waybill
                        if(shipmentOrderCodeData.source==2){
                            shipmentOrderCodeData.source='管理后台'
                        }
                        let info=statusListAdd.filter(item=>item.val==shipmentOrderCodeData.shipmentOrderStatus)
                        if(info.length){
                            shipmentOrderCodeData.shipmentOrderStatusName=info[0].name
                        }
                        let shipmentOrderDetailInfoList=shipmentOrderCodeData.orderInfoDetail
                        shipmentOrderDetailInfoList.map(item=>item.signQualified=1)
                        formData=shipmentOrderCodeData
                        table.reload("signCheckFormTable", {
                            data: shipmentOrderDetailInfoList
                        });
                        form.val("SignFormContent", shipmentOrderCodeData);
                    }
                }
            });
        })


        await admin.initDataSelectPro(
            "warehouse/warehouse/admin/administration/list",
            {limit: 99999},
            "warehouseId",
            "入库仓库",
            async (d, obj) => {
                if (d.value) {
                    admin.req(
                        "warehouse/warehouse/admin/warehouseFactoryArea/list",
                        {
                            warehouseId: d.value
                        },
                        (res) => {
                            warehouseAreaList = res.data;
                            let allTableCont=table.cache["signCheckFormTable"];
                            allTableCont.map(item=>{item.warehouseAreaId='';item.warehouseShelfSpaceId=''})
                            table.reload("signCheckFormTable",{data:allTableCont});
                        }
                    );
                }
            },
            "name"
        );

        table.on("tool(signCheckFormTable)", function (obj) {
            console.log(obj,"1")
            var d = obj.data; // 获取当前行的数据
            var layEvent = obj.event; // 获取事件名（edit 或 del）
            if (obj.tr) {
                obj.tr.on("click", function (e) {
                    e.preventDefault(); // 防止默认行为
                });
            }
            if (layEvent == "signClick") {
                if(d.signQualified===''){
                    layer.msg("请选择是否合格", {icon: 2, time: 1000});
                    return false;
                }
                if(d.signQualified==='0' && d.unqualifiedId===''){
                    layer.msg("请选择不合格原因", {icon: 2, time: 1000});
                    return false;
                }
                if(d.warehouseAreaId===''||d.warehouseAreaId==0){
                    layer.msg("请选择库区", {icon: 2, time: 1000});
                    return false;
                }
                if(d.warehouseShelfSpaceId===''||d.warehouseShelfSpaceId==0){
                    layer.msg("请选择库位", {icon: 2, time: 1000});
                    return false;
                }
                admin.req(
                    "warehouse/warehouse/signOrder/signSingle",{id: d.id,remarks:d.remarks,signQualified:d.signQualified,areaId:d.warehouseAreaId,spaceId:d.warehouseShelfSpaceId,unqualifiedId:d.unqualifiedId,unqualifiedReason:d.unqualifiedReason},(res) => {
                        layer.closeAll('loading');
                        if (res.code == 200) {
                            layer.msg(res.msg, {icon: 1});
                            layer.closeAll('page');
                            table.reload('warehouseSignOrderTable');
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }
                );
            }else if (layEvent == "review") {
                admin.req(
                    "warehouse/warehouse/productInventory/review",{id: d.id,signId:nowData.data.id},(res) => {
                        layer.closeAll('loading');
                        if (res.code == 200) {
                            layer.msg(res.msg, {icon: 1});
                            layer.closeAll('page');
                            table.reload('warehouseSignOrderTable');
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }
                );
            }else if(layEvent=='preview'){
                let zindex = admin.formOpen({
                    area: "30%",
                    offset: "25%",
                    title: "查看不合格原因及不合格图片",
                    content: $("#unqualifiedForm").html(),
                    success: function () {
                        $("#saveMaterialInfo").hide()
                        admin.initDataSelect('enterprise/dict/admin/dictLabel/list?dictType=unqualified_type', {limit: 9999}, "unqualifiedId",  d ? d.unqualifiedId : null, "不合格类型", 'labelName', null);
                        if (d != undefined) {
                            var picture = d.unqualifiedReason;
                            if (picture) {
                                $("#pictureDiv").html('<img src="' + picture + '" alt="上传成功后渲染" style="max-width: 196px"><input type="hidden" name="picture" value="' + picture + '">');
                            }
                            form.val('unqualifiedForm', d);
                        }
                        $("#pictureDiv").click(function (){
                            window.open(d.unqualifiedReason)
                        })
                    }
                });
            }


        });

        const tableVal = table.render({
            elem: '#signCheckFormTable',
            page: false,
            limit: 999999,
            height: 240,
            data: [],
            cols: [[
                {type: 'checkbox', fixed: 'left',
                    hide: nowData.eventName === "detail" ? true : false
                },
                {type: "numbers", title: "序号"},
                {field: 'userBundleDetail', title: '客户捆包号', align: 'center'}
                , {field: 'productSpecCode', title: '规格码', align: 'center'}
                , {field: 'productMark', title: '钢种/牌号', align: 'center'}
                , {field: 'productProducer', title: '产地', align: 'center'}
                , {field: 'productVariety', title: '品种', align: 'center'}
                , {field: 'productUnit', title: '计量单位', align: 'center'}
                , {field: 'totalQuantity', title: '数量', align: 'center'}
                , {
                    field: 'grossWeight', title: '毛重(吨)', align: 'center',
                    // templet: admin.setTableInput("grossWeight", nowData.eventName === "detail", "grossWeight")
                }
                , {
                    field: 'netWeight', title: '净重(吨)', align: 'center',
                    // templet: admin.setTableInput("netWeight", nowData.eventName === "detail", "netWeight")
                }
                ,
                {
                    field: 'signQualified', title: '是否合格', align: 'center',
                    templet:  (d)=>{
                        if (d.isSign==='1') {
                            return admin.setTableSelect("signQualified",
                                signQualifiedList.map((v) => {
                                    return {
                                        label: v.name,
                                        value: v.val
                                    };
                                }), d.isSign === "1", "signQualified")(d);
                        } else {
                            return admin.setTableSelect("signQualified",  signQualifiedList.map((v) => {
                                return {
                                    label: v.name,
                                    value: v.val
                                };
                            }), false, "signQualified")(d);
                        }
                    }
                },
                {
                    field: 'warehouseAreaId',
                    align: 'center',
                    title: '库区',
                    templet: function (d) {

                        if(d.warehouseAreaName!==''){
                            return d.warehouseAreaName
                        }else{
                            return admin.setTableSelect(
                                "warehouseAreaId",
                                warehouseAreaList.map((v) => {
                                    return {
                                        label: v.name,
                                        value: v.id
                                    };
                                }),
                                false,
                                "warehouseAreaId"
                            )(d);
                        }
                    }
                }, {
                    field: "warehouseShelfSpaceId",
                    align: "center",
                    title: "所在库位",
                    templet: function (d) {
                        if(d.warehouseShelfSpaceCode!==''){
                            return d.warehouseShelfSpaceCode
                        }else{
                            if (d.codeList) {
                                return admin.setTableSelect(
                                    "warehouseShelfSpaceId",
                                    d.codeList.map((v) => {
                                        return {
                                            label: v.code,
                                            value: v.id
                                        };
                                    }),
                                    false,
                                    "warehouseShelfSpaceId"
                                )(d);
                            }else{
                                return ''
                            }
                        }
                    }
                }
                , {
                    field: 'remarks', title: '备注', align: 'center',
                    templet:(d)=>{
                        if(d.isSign==='1'){
                            return admin.setTableInput("remarks", d.isSign === "1", "remarks")(d)
                        }else{
                            return admin.setTableInput("remarks", false, "remarks")(d)
                        }
                    }
                }
                , {
                    align: 'center',
                    toolbar: '#signcheckFormTableBar',
                    title: '操作',
                    width:180,
                    fixed: 'right',
                    hide: nowData.eventName === "detail" ? false : true
                }
            ]],
            done: function (res, page, count) {
                $('.layui-table-header input[name="layTableCheckbox"]').prop('checked', true)
                $('.layui-table-header input[name="layTableCheckbox"]').next().addClass('layui-form-checked')
                res.data.forEach((element, index) => {
                    element["LAY_CHECKED"]='true'
                    $('tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
                    $('tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
                });

                admin.tableInputChange("signCheckFormTable");
                // admin.tableSelectChange("signCheckFormTable", 'signQualified');

                admin.tableSelectChange("signCheckFormTable", "signQualified", (index, value, tableData, field) => {
                    console.log(value,index)
                    if(value==0){
                        nowIndex = index
                        var tableTwo
                        let zindex = admin.formOpen({
                            area: "20%",
                            offset: "25%",
                            title: "选择不合格原因及添加不合格图片",
                            content: $("#unqualifiedForm").html(),
                            success: function () {
                                admin.initDataSelect('enterprise/dict/admin/dictLabel/list?dictType=unqualified_type', {limit: 9999}, "unqualifiedId",  null, "不合格类型", 'labelName', null);
                                upload.render({
                                    elem: '#pictureDiv'
                                    , url: config.upload_url + 'uploadFile?path=' + img_path
                                    , auto: true
                                    , acceptMime: 'image/*'
                                    , headers: {authorization: 'Bearer ' + config.getToken()}
                                    , done: function (res) {
                                        layer.closeAll('loading');
                                        layer.msg('上传成功');
                                        var imgUrl = res.data.url;

                                        //上传完毕回调
                                        $("#pictureDiv").html('<img src="' + imgUrl + '" alt="上传成功后渲染" style="max-width: 196px"><input type="hidden" name="picture" value="' + imgUrl + '">');
                                    }
                                    , error: function (data) {
                                        layer.closeAll('loading');
                                    }
                                });
                            }
                        });

                        form.on('submit(saveMaterialInfo)', function (d) {
                            if(d.field.unqualifiedId==undefined||d.field.unqualifiedId==''){
                                layer.msg("请选择不合格原因", {icon: 2, time: 1000});
                                return false;
                            }
                            let list = table.cache["signCheckFormTable"];
                            let currentIndex = nowIndex;
                            if (currentIndex !== undefined && list[currentIndex]) {
                                list[currentIndex].unqualifiedId =d.field.unqualifiedId;
                                list[currentIndex].unqualifiedReason =d.field.picture;
                            }
                            table.reload("signCheckFormTable", {
                                data: list
                            });
                            layer.close(zindex);
                        });
                    }else{
                        tableData[index].unqualifiedId=''
                        tableData[index].unqualifiedReason=''
                        table.reload("signCheckFormTable", {
                            data: tableData
                        });
                    }
                });

                admin.tableSelectChange("signCheckFormTable", 'warehouseShelfSpaceId');
                // admin.tableSelectChange("signCheckFormTable", "warehouseAreaLId", (index, value, tableData, field) => {
                //     let obj=tableData[index].codeList.filter(i=>i.id==value)
                //     tableData[index].warehouseAreaLName = obj[0].code;
                //     table.reload("signCheckFormTable", {
                //         data: tableData
                //     });
                //
                // });
                admin.tableSelectChange("signCheckFormTable", "warehouseAreaId", (index, value, tableData, field) => {
                    admin.req(
                        "warehouse/warehouse/admin/warehouseFactoryShelfSpace/list",
                        {
                            warehouseAreaId: value
                        },
                        (res) => {
                            tableData[index].codeList = res.data;
                            tableData[index].warehouseShelfSpaceId=''
                            table.reload("signCheckFormTable", {
                                data: tableData
                            });

                        }
                    );
                });
            },
        });





        if (data && data.id) {
            console.log(data,"data")
            if(data.source==2){
                data.source='管理后台'
            }
            data.warehouseName=data.orderInfoDetail[0].warehouseName
            let info=statusList.filter(item=>item.val==data.shipmentOrderStatus)
            if(info.length){
                data.shipmentOrderStatusName=info[0].name
            }
            if(data.orderInfoDetail[0].warehouseId){
                let res=await admin.reqPro('warehouse/warehouse/admin/warehouseFactoryArea/list', {warehouseId:data.orderInfoDetail[0].warehouseId});
                warehouseAreaList=res.data
            }
            form.val("SignFormContent", data);
            tableVal.reload({
                data: data.orderInfoDetail.map((v) => {
                    v.eventName = "detail";

                    return v;
                })
            });
        } else {
        }

        //主框确定
        form.on("submit(signcheckFormSubmit)", function (d) {
            let allTableCont=table.cache["signCheckFormTable"];
            var checkRows = table.checkStatus('signCheckFormTable');
            var warehouseSignInventory=checkRows.data
            allTableCont.map((item)=>{
                item.warehouseId=$("#warehouseId").val()
                item.id=item.warehouseProductInventoryId
                if(item.LAY_CHECKED){
                    item.isSign='1'
                }else{
                    item.isSign='0'
                    item.warehouseAreaId=''
                    item.warehouseShelfSpaceId=''
                }
            })
            if($("#warehouseId").val()==''){
                layer.msg("请选择仓库", {icon: 2, time: 1000});
                return false;
            }
            if (warehouseSignInventory.some(item =>item.warehouseAreaId == undefined||item.warehouseAreaId == '')) {
                layer.msg("请选择库区", {icon: 2, time: 1000});
                return false;
            }
            if (warehouseSignInventory.some(item =>item.warehouseShelfSpaceId==undefined||item.warehouseShelfSpaceId == '')) {
                layer.msg("请选择库位", {icon: 2, time: 1000});
                return false;
            }
            if (warehouseSignInventory.length == 0) {
                layer.msg("请选择需要签收的数据");
                return false
            }
            if (warehouseSignInventory.some(item =>item.signQualified === '')) {
                layer.msg("请选择是否合格", {icon: 2, time: 1000});
                return false;
            }
            if (warehouseSignInventory.some(item =>item.signQualified === '0') && warehouseSignInventory.some(item =>item.unqualifiedId === '')) {
                layer.msg("请选择不合格的原因", {icon: 2, time: 1000});
                return false;
            }
            formData.totalQuantity=formData.totalWeight
            formData.warehouseId=$("#warehouseId").val()
            formData.source=2
            formData.shipmentOrderId=formData.id
            formData.customerId=formData.warehouseCustomerId
            formData.orderCode=formData.contractCode
            formData.totalQuantity=formData.totalWeight
            formData.warehouseSignInventory=allTableCont
            admin.req('warehouse/warehouse/signOrder/add',  JSON.stringify(formData), function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        layer.closeAll('page');
                        table.reload('warehouseSignOrderTable');
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, "POST",
                false,
                "application/json");

            return false;
        });


    });
</script>

<style>


    .chooseCode {
        position: relative;
    }

    .mask {
        position: absolute;
        width: 100%;
        height: 100%;
        background: rgba(158, 157, 157, 0.1);
        top: 50%;
        left: 50%;
        z-index: 2;
        transform: translate(-50%, -50%);
    }
</style>